﻿using System;

namespace Poly2Tri
{
	// Token: 0x02000416 RID: 1046
	public class Rect2D
	{
		// Token: 0x06001D8A RID: 7562 RVA: 0x000B60B9 File Offset: 0x000B42B9
		public Rect2D()
		{
			this.Clear();
		}

		// Token: 0x17000437 RID: 1079
		// (get) Token: 0x06001D8B RID: 7563 RVA: 0x000B60C7 File Offset: 0x000B42C7
		// (set) Token: 0x06001D8C RID: 7564 RVA: 0x000B60CF File Offset: 0x000B42CF
		public double MinX
		{
			get
			{
				return this.mMinX;
			}
			set
			{
				this.mMinX = value;
			}
		}

		// Token: 0x17000438 RID: 1080
		// (get) Token: 0x06001D8D RID: 7565 RVA: 0x000B60D8 File Offset: 0x000B42D8
		// (set) Token: 0x06001D8E RID: 7566 RVA: 0x000B60E0 File Offset: 0x000B42E0
		public double MaxX
		{
			get
			{
				return this.mMaxX;
			}
			set
			{
				this.mMaxX = value;
			}
		}

		// Token: 0x17000439 RID: 1081
		// (get) Token: 0x06001D8F RID: 7567 RVA: 0x000B60E9 File Offset: 0x000B42E9
		// (set) Token: 0x06001D90 RID: 7568 RVA: 0x000B60F1 File Offset: 0x000B42F1
		public double MinY
		{
			get
			{
				return this.mMinY;
			}
			set
			{
				this.mMinY = value;
			}
		}

		// Token: 0x1700043A RID: 1082
		// (get) Token: 0x06001D91 RID: 7569 RVA: 0x000B60FA File Offset: 0x000B42FA
		// (set) Token: 0x06001D92 RID: 7570 RVA: 0x000B6102 File Offset: 0x000B4302
		public double MaxY
		{
			get
			{
				return this.mMaxY;
			}
			set
			{
				this.mMaxY = value;
			}
		}

		// Token: 0x1700043B RID: 1083
		// (get) Token: 0x06001D93 RID: 7571 RVA: 0x000B60C7 File Offset: 0x000B42C7
		// (set) Token: 0x06001D94 RID: 7572 RVA: 0x000B60CF File Offset: 0x000B42CF
		public double Left
		{
			get
			{
				return this.mMinX;
			}
			set
			{
				this.mMinX = value;
			}
		}

		// Token: 0x1700043C RID: 1084
		// (get) Token: 0x06001D95 RID: 7573 RVA: 0x000B60D8 File Offset: 0x000B42D8
		// (set) Token: 0x06001D96 RID: 7574 RVA: 0x000B60E0 File Offset: 0x000B42E0
		public double Right
		{
			get
			{
				return this.mMaxX;
			}
			set
			{
				this.mMaxX = value;
			}
		}

		// Token: 0x1700043D RID: 1085
		// (get) Token: 0x06001D97 RID: 7575 RVA: 0x000B60FA File Offset: 0x000B42FA
		// (set) Token: 0x06001D98 RID: 7576 RVA: 0x000B6102 File Offset: 0x000B4302
		public double Top
		{
			get
			{
				return this.mMaxY;
			}
			set
			{
				this.mMaxY = value;
			}
		}

		// Token: 0x1700043E RID: 1086
		// (get) Token: 0x06001D99 RID: 7577 RVA: 0x000B60E9 File Offset: 0x000B42E9
		// (set) Token: 0x06001D9A RID: 7578 RVA: 0x000B60F1 File Offset: 0x000B42F1
		public double Bottom
		{
			get
			{
				return this.mMinY;
			}
			set
			{
				this.mMinY = value;
			}
		}

		// Token: 0x1700043F RID: 1087
		// (get) Token: 0x06001D9B RID: 7579 RVA: 0x000B610B File Offset: 0x000B430B
		public double Width
		{
			get
			{
				return this.Right - this.Left;
			}
		}

		// Token: 0x17000440 RID: 1088
		// (get) Token: 0x06001D9C RID: 7580 RVA: 0x000B611A File Offset: 0x000B431A
		public double Height
		{
			get
			{
				return this.Top - this.Bottom;
			}
		}

		// Token: 0x17000441 RID: 1089
		// (get) Token: 0x06001D9D RID: 7581 RVA: 0x000B6129 File Offset: 0x000B4329
		public bool Empty
		{
			get
			{
				return this.Left == this.Right || this.Top == this.Bottom;
			}
		}

		// Token: 0x06001D9E RID: 7582 RVA: 0x000B1856 File Offset: 0x000AFA56
		public override int GetHashCode()
		{
			return base.GetHashCode();
		}

		// Token: 0x06001D9F RID: 7583 RVA: 0x000B6150 File Offset: 0x000B4350
		public override bool Equals(object obj)
		{
			Rect2D rect2D = obj as Rect2D;
			if (rect2D != null)
			{
				return this.Equals(rect2D);
			}
			return base.Equals(obj);
		}

		// Token: 0x06001DA0 RID: 7584 RVA: 0x000B6179 File Offset: 0x000B4379
		public bool Equals(Rect2D r)
		{
			return this.Equals(r, MathUtil.EPSILON);
		}

		// Token: 0x06001DA1 RID: 7585 RVA: 0x000B6188 File Offset: 0x000B4388
		public bool Equals(Rect2D r, double epsilon)
		{
			return MathUtil.AreValuesEqual(this.MinX, r.MinX, epsilon) && MathUtil.AreValuesEqual(this.MaxX, r.MaxX) && MathUtil.AreValuesEqual(this.MinY, r.MinY, epsilon) && MathUtil.AreValuesEqual(this.MaxY, r.MaxY, epsilon);
		}

		// Token: 0x06001DA2 RID: 7586 RVA: 0x000B61F9 File Offset: 0x000B43F9
		public void Clear()
		{
			this.MinX = double.MaxValue;
			this.MaxX = double.MinValue;
			this.MinY = double.MaxValue;
			this.MaxY = double.MinValue;
		}

		// Token: 0x06001DA3 RID: 7587 RVA: 0x000B6237 File Offset: 0x000B4437
		public void Set(double xmin, double xmax, double ymin, double ymax)
		{
			this.MinX = xmin;
			this.MaxX = xmax;
			this.MinY = ymin;
			this.MaxY = ymax;
			this.Normalize();
		}

		// Token: 0x06001DA4 RID: 7588 RVA: 0x000B625C File Offset: 0x000B445C
		public void Set(Rect2D b)
		{
			this.MinX = b.MinX;
			this.MaxX = b.MaxX;
			this.MinY = b.MinY;
			this.MaxY = b.MaxY;
		}

		// Token: 0x06001DA5 RID: 7589 RVA: 0x000B628E File Offset: 0x000B448E
		public void SetSize(double w, double h)
		{
			this.Right = this.Left + w;
			this.Top = this.Bottom + h;
		}

		// Token: 0x06001DA6 RID: 7590 RVA: 0x000B62AC File Offset: 0x000B44AC
		public bool Contains(double x, double y)
		{
			return x > this.Left && y > this.Bottom && x < this.Right && y < this.Top;
		}

		// Token: 0x06001DA7 RID: 7591 RVA: 0x000B62DE File Offset: 0x000B44DE
		public bool Contains(Point2D p)
		{
			return this.Contains(p.X, p.Y);
		}

		// Token: 0x06001DA8 RID: 7592 RVA: 0x000B62F4 File Offset: 0x000B44F4
		public bool Contains(Rect2D r)
		{
			return this.Left < r.Left && this.Right > r.Right && this.Top < r.Top && this.Bottom > r.Bottom;
		}

		// Token: 0x06001DA9 RID: 7593 RVA: 0x000B6345 File Offset: 0x000B4545
		public bool ContainsInclusive(double x, double y)
		{
			return x >= this.Left && y >= this.Top && x <= this.Right && y <= this.Bottom;
		}

		// Token: 0x06001DAA RID: 7594 RVA: 0x000B637A File Offset: 0x000B457A
		public bool ContainsInclusive(double x, double y, double epsilon)
		{
			return x + epsilon >= this.Left && y + epsilon >= this.Top && x - epsilon <= this.Right && y - epsilon <= this.Bottom;
		}

		// Token: 0x06001DAB RID: 7595 RVA: 0x000B63B7 File Offset: 0x000B45B7
		public bool ContainsInclusive(Point2D p)
		{
			return this.ContainsInclusive(p.X, p.Y);
		}

		// Token: 0x06001DAC RID: 7596 RVA: 0x000B63CB File Offset: 0x000B45CB
		public bool ContainsInclusive(Point2D p, double epsilon)
		{
			return this.ContainsInclusive(p.X, p.Y, epsilon);
		}

		// Token: 0x06001DAD RID: 7597 RVA: 0x000B63E0 File Offset: 0x000B45E0
		public bool ContainsInclusive(Rect2D r)
		{
			return this.Left <= r.Left && this.Right >= r.Right && this.Top <= r.Top && this.Bottom >= r.Bottom;
		}

		// Token: 0x06001DAE RID: 7598 RVA: 0x000B6434 File Offset: 0x000B4634
		public bool ContainsInclusive(Rect2D r, double epsilon)
		{
			return this.Left - epsilon <= r.Left && this.Right + epsilon >= r.Right && this.Top - epsilon <= r.Top && this.Bottom + epsilon >= r.Bottom;
		}

		// Token: 0x06001DAF RID: 7599 RVA: 0x000B6490 File Offset: 0x000B4690
		public bool Intersects(Rect2D r)
		{
			return this.Right > r.Left && this.Left < r.Right && this.Bottom < r.Top && this.Top > r.Bottom;
		}

		// Token: 0x06001DB0 RID: 7600 RVA: 0x000B64E4 File Offset: 0x000B46E4
		public Point2D GetCenter()
		{
			return new Point2D((this.Left + this.Right) / 2.0, (this.Bottom + this.Top) / 2.0);
		}

		// Token: 0x06001DB1 RID: 7601 RVA: 0x000B6526 File Offset: 0x000B4726
		public bool IsNormalized()
		{
			return this.Right >= this.Left && this.Bottom <= this.Top;
		}

		// Token: 0x06001DB2 RID: 7602 RVA: 0x000B6550 File Offset: 0x000B4750
		public void Normalize()
		{
			if (this.Left > this.Right)
			{
				MathUtil.Swap<double>(ref this.mMinX, ref this.mMaxX);
			}
			if (this.Bottom < this.Top)
			{
				MathUtil.Swap<double>(ref this.mMinY, ref this.mMaxY);
			}
		}

		// Token: 0x06001DB3 RID: 7603 RVA: 0x000B65A4 File Offset: 0x000B47A4
		public void AddPoint(Point2D p)
		{
			this.MinX = Math.Min(this.MinX, p.X);
			this.MaxX = Math.Max(this.MaxX, p.X);
			this.MinY = Math.Min(this.MinY, p.Y);
			this.MaxY = Math.Max(this.MaxY, p.Y);
		}

		// Token: 0x06001DB4 RID: 7604 RVA: 0x000B660D File Offset: 0x000B480D
		public void Inflate(double w, double h)
		{
			this.Left -= w;
			this.Top += h;
			this.Right += w;
			this.Bottom -= h;
		}

		// Token: 0x06001DB5 RID: 7605 RVA: 0x000B6647 File Offset: 0x000B4847
		public void Inflate(double left, double top, double right, double bottom)
		{
			this.Left -= left;
			this.Top += top;
			this.Right += right;
			this.Bottom -= bottom;
		}

		// Token: 0x06001DB6 RID: 7606 RVA: 0x000B6682 File Offset: 0x000B4882
		public void Offset(double w, double h)
		{
			this.Left += w;
			this.Top += h;
			this.Right += w;
			this.Bottom += h;
		}

		// Token: 0x06001DB7 RID: 7607 RVA: 0x000B66BC File Offset: 0x000B48BC
		public void SetPosition(double x, double y)
		{
			double num = this.Right - this.Left;
			double num2 = this.Bottom - this.Top;
			this.Left = x;
			this.Bottom = y;
			this.Right = x + num;
			this.Top = y + num2;
		}

		// Token: 0x06001DB8 RID: 7608 RVA: 0x000B6708 File Offset: 0x000B4908
		public bool Intersection(Rect2D r1, Rect2D r2)
		{
			if (!TriangulationUtil.RectsIntersect(r1, r2))
			{
				double num = 0.0;
				this.Bottom = num;
				num = num;
				this.Top = num;
				num = num;
				this.Right = num;
				this.Left = num;
				return false;
			}
			this.Left = ((r1.Left <= r2.Left) ? r2.Left : r1.Left);
			this.Top = ((r1.Top >= r2.Top) ? r2.Top : r1.Top);
			this.Right = ((r1.Right >= r2.Right) ? r2.Right : r1.Right);
			this.Bottom = ((r1.Bottom <= r2.Bottom) ? r2.Bottom : r1.Bottom);
			return true;
		}

		// Token: 0x06001DB9 RID: 7609 RVA: 0x000B67F0 File Offset: 0x000B49F0
		public void Union(Rect2D r1, Rect2D r2)
		{
			if (r2.Right == r2.Left || r2.Bottom == r2.Top)
			{
				this.Set(r1);
			}
			else if (r1.Right == r1.Left || r1.Bottom == r1.Top)
			{
				this.Set(r2);
			}
			else
			{
				this.Left = ((r1.Left >= r2.Left) ? r2.Left : r1.Left);
				this.Top = ((r1.Top <= r2.Top) ? r2.Top : r1.Top);
				this.Right = ((r1.Right <= r2.Right) ? r2.Right : r1.Right);
				this.Bottom = ((r1.Bottom >= r2.Bottom) ? r2.Bottom : r1.Bottom);
			}
		}

		// Token: 0x04001DDB RID: 7643
		private double mMinX;

		// Token: 0x04001DDC RID: 7644
		private double mMaxX;

		// Token: 0x04001DDD RID: 7645
		private double mMinY;

		// Token: 0x04001DDE RID: 7646
		private double mMaxY;
	}
}
